package com.iafme.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iafme.dto.req.OrderReqDTO;
import com.iafme.dto.res.MemberOrderCourseResDTO;
import com.iafme.dto.res.MemberOrderResDTO;
import com.iafme.dto.res.OrderResDTO;
import com.iafme.model.OrderCourse;
import com.iafme.service.IOrderService;
import com.iafme.service.OrderCourseService;
import com.systemframework.common.BaseCommonInterface;
import com.systemframework.constants.Constants;
import com.systemframework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author summer
 * @version 1.0
 * @date 2025/2/17 19:59
 */
@RestController
@RequestMapping(value = "/exam")
@AllArgsConstructor
public class OrderExamController implements BaseCommonInterface<OrderReqDTO, OrderResDTO> {

    private final IOrderService orderService;

    @Override
    public Result<String> save(@Valid OrderReqDTO reqDTO) {
        return null;
    }

    @Override
    public Result<String> update(@Valid OrderReqDTO reqDTO) {
        return null;
    }

    @Override
    public Result<String> del(Integer id) {
        return null;
    }

    @Override
    public Result<Page<OrderResDTO>> lists(OrderReqDTO reqDTO) {
        return Result.successResult(orderService.lists(reqDTO));
    }

    @Override
    public Result<OrderResDTO> findById(Integer integer) {
        return null;
    }

    @Override
    public Result<String> batchDel(List<OrderResDTO> list) {
        return null;
    }

    @GetMapping(value = "/findMemberOrderById/{id}")
    public MemberOrderResDTO findMemberOrderById(@PathVariable("id") Integer id) {

        return orderService.findMemberOrder(id);
    }

    private final OrderCourseService orderCourseService;

    @PutMapping(value = "/updateScore")
    public String updateScore(@RequestBody MemberOrderCourseResDTO courseResDTO){
        OrderCourse orderCourse = Convert.convert(OrderCourse.class, courseResDTO);
        orderCourseService.updateById(orderCourse);
        return Constants.SUCESS;
    }

}
